import {Component, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {Product} from "../product";


@Component({
  selector: 'app-myc04-productlist',
  templateUrl: './myc04-productlist.component.html',
  styleUrls: ['./myc04-productlist.component.css']
})
export class Myc04ProductlistComponent implements OnInit {

  productList: Product[] = []
  private pageSize: number = 5
  private pageNum: number = 0

  constructor(private http: HttpClient) {
  }

  ngOnInit(): void {
    this.loadMore()
  }

  public loadMore(): void {
    this.pageNum += 1
    let url = `http://localhost:8080/product/list?pageSize=${this.pageSize}&pageNum=${this.pageNum}`
    this.http.get(url).subscribe((res: any) => {
      this.productList = res.data.list
      console.log(res.data.list)
    })
  }
}
